﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Enterprise.Model.Role;
using Enterprise.Service.Role;
using Enterprise.Infrastructure;
using Enterprise.Control;
namespace Enterprise.UI.Web.Manage.Role
{
    public partial class Edit : System.Web.UI.Page
    {
        int Id = (int)Utility.sink("Id", Utility.MethodType.Get, 0, 0, Utility.DataType.Int);
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                OnStart();
            }
        }

        private void OnStart()
        {
            OnBindData();
        }

        private void OnBindData()
        {
            RoleService ser = new RoleService();
            var q = ser.RoleDisp(Id);
            if (q != null)
            {
                rName.Text = q.RNAME;
                //ListItem li = rType.Items.FindByValue(q.RTYPE);
                //if (li != null)
                //    li.Selected = true;
                rRemark.Text = q.RREMARK;
                //添加返回按钮
                CreateBT.AddButton("back.gif", "返回", string.Format("Index.aspx"), Utility.PopedomType.List, HeadMenuWebControls1);
            }
        }

        protected void Button1_OnClick(object sender, EventArgs e)
        {
            RoleService ser = new RoleService();
            var um = ser.RoleDisp(Id);
            if (um != null)
            {
                um.DB_Option_Action = "Update";
                um.RNAME = (string)Utility.sink(rName.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Str);
                um.RTYPE = "";//(string)Utility.sink(rType.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Str);
                um.RREMARK = (string)Utility.sink(rRemark.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Str);
                ser.RoleExecute(um);
                Response.Redirect("Index.aspx");
                Response.End();
            }
        }

    }
}